/*
 * http://zhedahht.blog.163.com/blog/static/25411174200793181548842
 */

// method 1
// FinalClass is on available on heap.
class Test;
class FinalClass {
	// friend class Test;
private:
	FinalClass(){};

public:
	static FinalClass *GetInstence( void ) {
		return new FinalClass();
	}
};

// method 2
// FinalClass2 is available in heap and stack.
template < typename T >
class identify
{
public:
	typedef T me;
};


template < typename T >
class make_final
{
	friend class identify< T >::me;
	// friend T; is not allowed.
	// from : http://bytes.com/topic/c/answers/595256-new-template-rules-bad 
	// to solve this.

private:
	make_final() {}
	~make_final() {}
};

class FinalClass2 : public virtual make_final < FinalClass2 >
{
public:
	FinalClass2(){}
	~FinalClass2(){}
};

class Test : public FinalClass
{
};

int main( int argc, char *argv[] )
{
	// Test t;
}

